import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:tcpsocket/tcpsocket.dart';

// void main() {
//   test('adds one to input values', () {
//     final calculator = Calculator();
//     expect(calculator.addOne(2), 3);
//     expect(calculator.addOne(-7), -6);
//     expect(calculator.addOne(0), 1);
//
//     final sock = SocketClient("127.0.0.1", 8081 ,onConnect: (client){
//       debugPrint("onConnected");
//     },onData:(client,cmd){
//
//     });
//
//     sock.connect();
//     debugPrint("sock.host= ${sock.host}");
//     debugPrint("sock.reconnectCount= ${sock.reconnectCount}");
//     debugPrint("sock.port= ${sock.port}");
//
//   });
// }



Future main() async {
  final sock = SocketClient("127.0.0.1", 8081, onConnect: (client) {
    debugPrint("onConnected");
    client.send({
      'name': "login",
      'data': {"uid": 123, "roomid": "123456"}
    });
  }, onData: (client, cmd) {
    debugPrint("onData= $cmd");
    // client.close();

  },onDone: (client){
    debugPrint("onDone");
  },reconnectCount: 3,reconnectInterval: 10000);

  sock.connect();
  debugPrint("sock.host= ${sock.host}");
  debugPrint("sock.reconnectCount= ${sock.reconnectCount}");
  debugPrint("sock.reconnectInterval= ${sock.reconnectInterval}");
  debugPrint("sock.port= ${sock.port}");

  while (true) {
    await Future.delayed(const Duration(seconds: 1), () {});
  }
}
